package com.jerry.shop.mapper;

import com.jerry.shop.bean.Buyer;
import org.apache.ibatis.annotations.*;

import java.util.List;

//这是Buyer操作数据库的mapper
@Mapper
public interface BuyerMapper {

    @Select("select * from t_buyer")
    public List<Buyer> getBuyerList();

    @Select("select * from t_buyer where id=#{id}")
    public Buyer getBuyerById(Integer id);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into t_buyer(username, password, phone, address) values(#{username}, #{password}, #{phone}, #{address})")
    public int insertBuyer(Buyer buyer);

    @Update("update t_buyer set username=#{username}, password=#{password}, phone=#{phone}, address=#{address} where id=#{id}")
    public int updateBuyer(Buyer buyer);

    @Delete("delete from t_buyer where id=#{id}")
    public int deleteBuyerById(Integer id);

}
